package com.yz.jdd.module.main.adapter;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.yz.jdd.R;
import com.yz.jdd.base.entity.Image;
import com.yz.jdd.module.main.entity.FilterBean;
import com.yz.jdd.module.main.entity.OrderTypeBean;

import java.util.List;

/**
 * 订单title 下拉列表
 */
public class OrderTypeAdapter extends BaseAdapter {

    private Context context;
    private List<OrderTypeBean> beanList;

    public OrderTypeAdapter(Context context, List<OrderTypeBean> beanList) {
        this.context = context;
        this.beanList = beanList;
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public Object getItem(int i) {
        return beanList.get(i);
    }

    @Override
    public int getCount() {
        return beanList.size();
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        ViewHolder viewHolder;
        if (view == null) {
            view = LayoutInflater.from(context).inflate(R.layout.popu_order_type_item, viewGroup, false);
            viewHolder = new ViewHolder();
            viewHolder.nameTextView = (TextView) view.findViewById(R.id.type_name);
            viewHolder.imageView = (ImageView) view.findViewById(R.id.select_img);
            view.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) view.getTag();
        }
        viewHolder.nameTextView.setText(beanList.get(i).getTypeName());
        if (beanList.get(i).isSelect()) {
            viewHolder.imageView.setVisibility(View.VISIBLE);
            viewHolder.nameTextView.setTextColor(Color.parseColor("#459DFF"));
        } else {
            viewHolder.imageView.setVisibility(View.GONE);
            viewHolder.nameTextView.setTextColor(Color.parseColor("#333333"));
        }
        return view;
    }

    class ViewHolder {
        TextView nameTextView;
        ImageView imageView;
    }
}
